<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="fb:admins" content="{100004477576763}"/>

    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap.css.map">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap-theme.css.map">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/css/bootstrap-theme.min.css">

    <link href="<?php echo base_url() ?>assets/css/style.css" rel="stylesheet" type="text/css">
    <link href="<?php echo base_url() ?>assets/css/style-responsive.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" href="<?php echo base_url() ?>assets/css/main.css" type="text/css">

    <script src="<?php echo base_url() ?>assets/js/jquery-1.11.1.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery-1.11.1.min.js"></script>
    <script src="<?php echo base_url();?>assets/js/jquery-2.1.1.min.js"></script>
    <script src="<?php echo base_url();?>assets/js/jquery-1.11.1.min.map"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery.form.js"></script>
    <script src="<?php echo base_url();?>assets/js/jquery-migrate-1.2.1.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery-ui.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery.ui.core.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery.ui.widget.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery.ui.position.js"></script>
    <script src="<?php echo base_url() ?>assets/js/jquery.ui.autocomplete.js"></script>

    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/jquery-ui.css">

    <script src="<?php echo base_url() ?>assets/js/bootstrap.js"></script>
    <script src="<?php echo base_url() ?>assets/js/bootstrap.min.js"></script>

    <script type="text/javascript" src="<?php echo base_url() ?>assets/ckeditor/ckeditor.js" charset="utf-8"></script>

    <script>
        function lightbox_open(idLight, idFade){
            window.scrollTo(0,0);
            document.getElementById(idLight).style.display='block';
            document.getElementById(idFade).style.display='block';
        }

        function lightbox_close(idLight, idFade){
            document.getElementById(idLight).style.display='none';
            document.getElementById(idFade).style.display='none';
        }
    </script>

    <script language="Javascript">
        function fileUpload(form, action_url, div_id, div_upload, div_preview) {
            // Create the iframe...
            var iframe = document.createElement("iframe");
            iframe.setAttribute("id", "upload_iframe");
            iframe.setAttribute("name", "upload_iframe");
            iframe.setAttribute("width", "0");
            iframe.setAttribute("height", "0");
            iframe.setAttribute("border", "0");
            iframe.setAttribute("style", "width: 0; height: 0; border: none;");

            // Add to document...
            form.parentNode.appendChild(iframe);
            window.frames['upload_iframe'].name = "upload_iframe";

            iframeId = document.getElementById("upload_iframe");

            // Add event...
            var eventHandler = function () {

                if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
                else iframeId.removeEventListener("load", eventHandler, false);

                // Message from server...
                if (iframeId.contentDocument) {
                    content = iframeId.contentDocument.body.innerHTML;
                } else if (iframeId.contentWindow) {
                    content = iframeId.contentWindow.document.body.innerHTML;
                } else if (iframeId.document) {
                    content = iframeId.document.body.innerHTML;
                }

                if(content != "<p>You did not select a file to upload.</p>"){
                    var num = content.split(/[^ \t\r\n]/)[0].length; //dem so khoang trang
//                alert(num);
                    if(num == 0){
                        var idDiv2 = $('#'+div_upload+'').val();
//                    alert(idDiv2);
                        var divID2 = document.getElementById(idDiv2);
                        divID2.style.backgroundSize = "70px 60px";
                        divID2.style.backgroundImage = "url('<?php echo base_url() ?>uploads/"+content+"')";
                        $('#'+div_preview+'').attr('src', '<?php echo base_url() ?>uploads/'+content+'');
                    }
                }

//            alert(content);
                document.getElementById(div_id).innerHTML = content;

                // Del the iframe...
                setTimeout('iframeId.parentNode.removeChild(iframeId)', 250);
            }

            if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
            if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);

            // Set properties of form...
            form.setAttribute("target", "upload_iframe");
            form.setAttribute("action", action_url);
            form.setAttribute("method", "post");
            form.setAttribute("enctype", "multipart/form-data");
            form.setAttribute("encoding", "multipart/form-data");

            // Submit the form...
            form.submit();

            document.getElementById(div_id).innerHTML = "Đang tải tập tin...";
        }
    </script>

</head>
